<%@ page import="com.whr.bean.Problem" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" href="/layui/css/layui.css" media="all">
    <script src="/layui/layui.js" charset="utf-8"></script>
    <script src="/js/jquery.2.1.4.js" charset="utf-8"></script>
    <script type="text/javascript">
        <%
           Problem prob = (Problem)request.getAttribute("prob");
           String ptext = prob.getPtext();
           %>
        $(function () {
            var content = '<%=ptext%>';
            //判断ueditor 编辑器是否创建成功
            ue.addListener("ready", function () {
                // editor准备好之后才可以使用
                ue.setContent(content);

            });
        });
    </script>
</head>
<body>
<div style="margin: 60px auto;width: 80%">
    <form id="probform" class="layui-form layui-form-pane" action="/prob/edit">
        <div class="layui-form-item">
            <label class="layui-form-label">标题</label>
            <div class="layui-input-block">
                <input type="text" name="ptitle" value="${prob.ptitle}" required lay-verify="required"
                       autocomplete="off"
                       class="layui-input">
            </div>
        </div>
        <input id="ptext" type="hidden" name="ptext">
        <input type="hidden" name="pid" value="${prob.pid}">
        <input type="hidden" name="pdate" value="${prob.pdate}">
        <input type="hidden" name="pstate" value="${prob.pstate}">
        <div class="layui-form-item">
            <div>
                <script id="container" name="content" type="text/plain">
                </script>
                <!-- 配置文件 -->
                <script type="text/javascript" src="/ueditor/ueditor.config.js"></script>
                <!-- 编辑器源码文件 -->
                <script type="text/javascript" src="/ueditor/ueditor.all.js"></script>
                <!-- 实例化编辑器 -->
                <script type="text/javascript">
                    var ue = UE.getEditor('container', {
                        //initialFrameWidth :800
                        initialFrameHeight: 250,//设置编辑器高度
                        scaleEnabled: true,
                    });

                    function upprob() {
                        //var ue = UE.getEditor('container');
                        var str = ue.getContent();
                        $("#ptext").val(str);
                        $("#probform").submit();

                    }
                </script>
            </div>
            <div>
                <button type="button" class="layui-btn" style="margin-top: 10px" onclick="upprob();">提交</button>
            </div>
        </div>
    </form>
</div>
</body>
</html>
